<?php
include(getabspath("include/proforma_invoices_settings.php"));

function DisplayMasterTableInfo_proforma_invoices($params)
{
	$detailtable=$params["detailtable"];
	$keys=$params["keys"];
	global $conn,$strTableName;
	$xt = new Xtempl();
	$oldTableName=$strTableName;
	$strTableName="proforma_invoices";

//$strSQL = "SELECT  id,  account_id,  'account_address' AS account_address,  buyer_id,  '1' AS buyer_address,  consignee_id,  '1' AS consignee_address,  notify_id,  '1' AS notify_address,  proforma_invoice_no,  proforma_invoice_date,  customer_reference,  customer_reference_date,  commercial_invoice_no,  commercial_invoice_date,  term_of_sale1,  term_of_sale2,  shipment_mode_id,  estimated_shipment_date,  estimated_shipment_date_custom,  additional_charges_frieght_type,  additional_charges_legalization,  additional_charges_inspection,  additional_charges_special_packing,  others1_key,  others2_key,  others3_key,  others1_value,  others2_value,  others3_value,  payment_term_id,  payment_term_other,  bank_name_id,  bank_term1,  bank_term2,  currency_id,  terms_and_conditions  FROM proforma_invoices  ";

$sqlHead="SELECT id,  account_id,  'account_address' AS account_address,  buyer_id,  '1' AS buyer_address,  consignee_id,  '1' AS consignee_address,  notify_id,  '1' AS notify_address,  proforma_invoice_no,  proforma_invoice_date,  customer_reference,  customer_reference_date,  commercial_invoice_no,  commercial_invoice_date,  term_of_sale1,  term_of_sale2,  shipment_mode_id,  estimated_shipment_date,  estimated_shipment_date_custom,  additional_charges_frieght_type,  additional_charges_legalization,  additional_charges_inspection,  additional_charges_special_packing,  others1_key,  others2_key,  others3_key,  others1_value,  others2_value,  others3_value,  payment_term_id,  payment_term_other,  bank_name_id,  bank_term1,  bank_term2,  currency_id,  terms_and_conditions";
$sqlFrom="FROM proforma_invoices";
$sqlWhere="";
$sqlTail="";

$where="";
$mKeys = array();
$showKeys = "";

if($detailtable=="proforma_invoice_items")
{
		$where.= GetFullFieldName("id")."=".make_db_value("id",$keys[1-1]);
	$showKeys .= " Id: ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
}
	if(!$where)
	{
		$strTableName=$oldTableName;
		return;
	}
	$str = SecuritySQL("Search");
	if(strlen($str))
		$where.=" and ".$str;

	$strWhere=whereAdd($sqlWhere,$where);
	if(strlen($strWhere))
		$strWhere=" where ".$strWhere." ";
	$strSQL= $sqlHead.' '.$sqlFrom.$strWhere.$sqlTail;

//	$strSQL=AddWhere($strSQL,$where);
	LogInfo($strSQL);
	$rs=db_query($strSQL,$conn);
	$data=db_fetch_array($rs);
	if(!$data)
	{
		$strTableName=$oldTableName;
		return;
	}
	$keylink="";
	$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["id"]));
	


//	id - 
			$value="";
				$value = ProcessLargeText(GetData($data,"id", ""),"field=id".$keylink);
			$xt->assign("id_mastervalue",$value);

//	account_id - 
			$value="";
				$value=DisplayLookupWizard("account_id",$data["account_id"],$data,$keylink,MODE_LIST);
			$xt->assign("account_id_mastervalue",$value);

//	account_address - 
			$value="";
				$value = ProcessLargeText(GetData($data,"account_address", ""),"field=account%5Faddress".$keylink);
			$xt->assign("account_address_mastervalue",$value);

//	buyer_id - 
			$value="";
				$value=DisplayLookupWizard("buyer_id",$data["buyer_id"],$data,$keylink,MODE_LIST);
			$xt->assign("buyer_id_mastervalue",$value);

//	buyer_address - 
			$value="";
				$value = ProcessLargeText(GetData($data,"buyer_address", ""),"field=buyer%5Faddress".$keylink);
			$xt->assign("buyer_address_mastervalue",$value);

//	consignee_id - 
			$value="";
				$value=DisplayLookupWizard("consignee_id",$data["consignee_id"],$data,$keylink,MODE_LIST);
			$xt->assign("consignee_id_mastervalue",$value);

//	consignee_address - 
			$value="";
				$value = ProcessLargeText(GetData($data,"consignee_address", ""),"field=consignee%5Faddress".$keylink);
			$xt->assign("consignee_address_mastervalue",$value);

//	notify_id - 
			$value="";
				$value=DisplayLookupWizard("notify_id",$data["notify_id"],$data,$keylink,MODE_LIST);
			$xt->assign("notify_id_mastervalue",$value);

//	notify_address - 
			$value="";
				$value = ProcessLargeText(GetData($data,"notify_address", ""),"field=notify%5Faddress".$keylink);
			$xt->assign("notify_address_mastervalue",$value);

//	proforma_invoice_no - 
			$value="";
				$value = ProcessLargeText(GetData($data,"proforma_invoice_no", ""),"field=proforma%5Finvoice%5Fno".$keylink);
			$xt->assign("proforma_invoice_no_mastervalue",$value);

//	proforma_invoice_date - Short Date
			$value="";
				$value = ProcessLargeText(GetData($data,"proforma_invoice_date", "Short Date"),"field=proforma%5Finvoice%5Fdate".$keylink);
			$xt->assign("proforma_invoice_date_mastervalue",$value);

//	customer_reference - 
			$value="";
				$value = ProcessLargeText(GetData($data,"customer_reference", ""),"field=customer%5Freference".$keylink);
			$xt->assign("customer_reference_mastervalue",$value);

//	customer_reference_date - Short Date
			$value="";
				$value = ProcessLargeText(GetData($data,"customer_reference_date", "Short Date"),"field=customer%5Freference%5Fdate".$keylink);
			$xt->assign("customer_reference_date_mastervalue",$value);

//	commercial_invoice_no - 
			$value="";
				$value = ProcessLargeText(GetData($data,"commercial_invoice_no", ""),"field=commercial%5Finvoice%5Fno".$keylink);
			$xt->assign("commercial_invoice_no_mastervalue",$value);

//	commercial_invoice_date - Short Date
			$value="";
				$value = ProcessLargeText(GetData($data,"commercial_invoice_date", "Short Date"),"field=commercial%5Finvoice%5Fdate".$keylink);
			$xt->assign("commercial_invoice_date_mastervalue",$value);

//	term_of_sale1 - 
			$value="";
				$value = ProcessLargeText(GetData($data,"term_of_sale1", ""),"field=term%5Fof%5Fsale1".$keylink);
			$xt->assign("term_of_sale1_mastervalue",$value);

//	term_of_sale2 - 
			$value="";
				$value = ProcessLargeText(GetData($data,"term_of_sale2", ""),"field=term%5Fof%5Fsale2".$keylink);
			$xt->assign("term_of_sale2_mastervalue",$value);

//	shipment_mode_id - 
			$value="";
				$value=DisplayLookupWizard("shipment_mode_id",$data["shipment_mode_id"],$data,$keylink,MODE_LIST);
			$xt->assign("shipment_mode_id_mastervalue",$value);

//	estimated_shipment_date - Short Date
			$value="";
				$value = ProcessLargeText(GetData($data,"estimated_shipment_date", "Short Date"),"field=estimated%5Fshipment%5Fdate".$keylink);
			$xt->assign("estimated_shipment_date_mastervalue",$value);

//	estimated_shipment_date_custom - 
			$value="";
				$value = ProcessLargeText(GetData($data,"estimated_shipment_date_custom", ""),"field=estimated%5Fshipment%5Fdate%5Fcustom".$keylink);
			$xt->assign("estimated_shipment_date_custom_mastervalue",$value);

//	additional_charges_frieght_type - 
			$value="";
				$value = ProcessLargeText(GetData($data,"additional_charges_frieght_type", ""),"field=additional%5Fcharges%5Ffrieght%5Ftype".$keylink);
			$xt->assign("additional_charges_frieght_type_mastervalue",$value);

//	additional_charges_legalization - 
			$value="";
				$value = ProcessLargeText(GetData($data,"additional_charges_legalization", ""),"field=additional%5Fcharges%5Flegalization".$keylink);
			$xt->assign("additional_charges_legalization_mastervalue",$value);

//	additional_charges_inspection - 
			$value="";
				$value = ProcessLargeText(GetData($data,"additional_charges_inspection", ""),"field=additional%5Fcharges%5Finspection".$keylink);
			$xt->assign("additional_charges_inspection_mastervalue",$value);

//	additional_charges_special_packing - 
			$value="";
				$value = ProcessLargeText(GetData($data,"additional_charges_special_packing", ""),"field=additional%5Fcharges%5Fspecial%5Fpacking".$keylink);
			$xt->assign("additional_charges_special_packing_mastervalue",$value);

//	others1_key - 
			$value="";
				$value = ProcessLargeText(GetData($data,"others1_key", ""),"field=others1%5Fkey".$keylink);
			$xt->assign("others1_key_mastervalue",$value);

//	others2_key - 
			$value="";
				$value = ProcessLargeText(GetData($data,"others2_key", ""),"field=others2%5Fkey".$keylink);
			$xt->assign("others2_key_mastervalue",$value);

//	others3_key - 
			$value="";
				$value = ProcessLargeText(GetData($data,"others3_key", ""),"field=others3%5Fkey".$keylink);
			$xt->assign("others3_key_mastervalue",$value);

//	others1_value - 
			$value="";
				$value = ProcessLargeText(GetData($data,"others1_value", ""),"field=others1%5Fvalue".$keylink);
			$xt->assign("others1_value_mastervalue",$value);

//	others2_value - 
			$value="";
				$value = ProcessLargeText(GetData($data,"others2_value", ""),"field=others2%5Fvalue".$keylink);
			$xt->assign("others2_value_mastervalue",$value);

//	others3_value - 
			$value="";
				$value = ProcessLargeText(GetData($data,"others3_value", ""),"field=others3%5Fvalue".$keylink);
			$xt->assign("others3_value_mastervalue",$value);

//	payment_term_id - 
			$value="";
				$value=DisplayLookupWizard("payment_term_id",$data["payment_term_id"],$data,$keylink,MODE_LIST);
			$xt->assign("payment_term_id_mastervalue",$value);

//	payment_term_other - 
			$value="";
				$value = ProcessLargeText(GetData($data,"payment_term_other", ""),"field=payment%5Fterm%5Fother".$keylink);
			$xt->assign("payment_term_other_mastervalue",$value);

//	bank_name_id - 
			$value="";
				$value=DisplayLookupWizard("bank_name_id",$data["bank_name_id"],$data,$keylink,MODE_LIST);
			$xt->assign("bank_name_id_mastervalue",$value);

//	bank_term1 - 
			$value="";
				$value = ProcessLargeText(GetData($data,"bank_term1", ""),"field=bank%5Fterm1".$keylink);
			$xt->assign("bank_term1_mastervalue",$value);

//	bank_term2 - 
			$value="";
				$value = ProcessLargeText(GetData($data,"bank_term2", ""),"field=bank%5Fterm2".$keylink);
			$xt->assign("bank_term2_mastervalue",$value);

//	currency_id - 
			$value="";
				$value=DisplayLookupWizard("currency_id",$data["currency_id"],$data,$keylink,MODE_LIST);
			$xt->assign("currency_id_mastervalue",$value);

//	terms_and_conditions - 
			$value="";
				$value = ProcessLargeText(GetData($data,"terms_and_conditions", ""),"field=terms%5Fand%5Fconditions".$keylink);
			$xt->assign("terms_and_conditions_mastervalue",$value);
	$xt->display("proforma_invoices_masterlist.htm");
	$strTableName=$oldTableName;
}

?>